package gameUi.panel
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;

	public class ChoosePanel extends ChoosePanelMC
	{
		private static var instance:ChoosePanel;
		
		public function ChoosePanel(key:Key)
		{
			label.mouseEnabled = false;
			label.mouseChildren = false;
			if(BlackJack._gameUi.tipsIsum){
				label.gotoAndStop(2);
			}else{
				label.gotoAndStop(1);
			}
			cmdIssum.addEventListener(MouseEvent.CLICK,clickIssum);
			cmdClose.addEventListener(MouseEvent.CLICK,clickClose);
			bg.addEventListener(MouseEvent.MOUSE_DOWN,onBeginDrag);
			BlackJack._stage.addEventListener(MouseEvent.MOUSE_UP,onStopDrag);
		}
		
		public static function getInstance():ChoosePanel{
			if(!instance) instance = new ChoosePanel(new Key());
			return instance;
		}
		
		private function clickIssum(e:MouseEvent):void{
			if(BlackJack._gameUi.tipsIsum){
				BlackJack._gameUi.tipsIsum = false;
				label.gotoAndStop(1);
			}else{
				BlackJack._gameUi.tipsIsum = true;
				label.gotoAndStop(2);
			}
		}
		
		private function clickClose(e:MouseEvent = null):void{
			if(this.parent) this.parent.removeChild(this);
		}
		
		private function onBeginDrag(e:MouseEvent):void{
			this.startDrag();
		}
		
		private function onStopDrag(e:MouseEvent):void{
			this.stopDrag();
		}
		
		public function showPanel():void{
			if(BlackJack._stage.contains(this)){
				BlackJack._stage.removeChild(this);
			}else{
				this.x = BlackJack._stage.stageWidth/2;
				this.y = BlackJack._stage.stageHeight/2;
				BlackJack._stage.addChild(this);
			}
		}
	}
}
class Key{}